-module(pattern1).
-include("class1.class.hrl").
-include("class2.class.hrl").

-export([d0/1]).

-record(rec, {a, b, c}).

a0(Obj) ->
    (Obj#class1.field1)#class2.field2.

d0(A) ->
    setelement(4, A, 2),
    setelement(5, A, 2),
    setelement(6, A, 2).

demo(Obj) ->
    #class1{field1 = 5, field2 = B} = Obj,
    B.

demo2(Obj) when Obj#class1.field1 =:= 5 ->
    #class1{field1 = 5, field2 = B} = Obj,
    B.

demo3(Obj) ->
    [_,#class1{field1 = 5, field2 = A},#class2{z = B}|_] = Obj.

demo4(Obj) ->
    #class1{field1 = {A, B}, field2 = A} = Obj.

demo5(Obj) ->
    #class1{field1 = #class2{x = {5, B}}, field2 = A} = Obj.
    
clausedemo1(A = {_, #class1{field2 = B, field3 = C}}, C)->
    A-B+C.